package com.defangit.production.orm;

import com.defangit.production.bll.AbstractStoreBll;
import com.defangit.production.domain.AbstractStore;
import laogen.hibernate.CommonFinder;
import laogen.hibernate.CommonService;
import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;

import java.util.Optional;

public class AbstractStoreService extends CommonService<AbstractStore> implements AbstractStoreBll {
    @Override
    public AbstractStore addAbstractStore(AbstractStore store) {
        return null;
    }

    @Override
    public AbstractStoreFinder findAll() {
        return new AbstractStoreFinderImp();
    }

    public class AbstractStoreFinderImp extends CommonFinder<AbstractStore> implements AbstractStoreFinder {
        private DetachedCriteria storeCriteria;
        private AbstractStoreFinderImp(){
            this.storeCriteria = detachedAll();
        }

        @Override
        public Criteria getCriteria() {
            return this.storeCriteria.getExecutableCriteria(getSession());
        }

        @Override
        public DetachedCriteria getDetachedCriteria() {
            return this.storeCriteria;
        }

        @Override
        public AbstractStoreFinder storeName(String name) {
            if (name==null) return this;
            return this;
        }
    }

}
